package option;

import Book.BookList;
import Book.Book;
import java.util.Scanner;

public class Serch implements MY{
    @Override
    public void work(BookList booklist) {
        System.out.println("查找图书");
        System.out.println("请输入你要查找的书名：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();//切记
        //遍历数组，查找图书
        int size=booklist.getUsedSize();
        for (int i=0;i<size;i++){
            Book book=booklist.getBooks(i);
            if(book.getName().equals(name)){
                System.out.println("找到了这本书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有您查找到图书！");
    }
}
